
<%@page import="com.crossriver.crgis.database.model.Held_Plots"%>
<%@page import="com.liferay.portal.service.ListTypeServiceUtil"%>
<%@page import="com.liferay.portal.model.ListType"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@page import="com.crossriver.crgis.database.model.Property_Information"%>
<%@ page import="com.crossriver.crgis.database.model.Application_C_of_O" %>
<%@ page import="com.crossriver.crgis.cofo.util.ApplicationCofOConstants" %>
<%@ include file="/init.jsp"%> 
<%@page import="com.liferay.portal.model.Country"%>
<%@page import="com.liferay.portal.service.CountryServiceUtil"%>
<%@page import="com.crossriver.crgis.database.service.persistence.Application_C_of_OUtil"%>
<%
Property_Information propInfo =
		(Property_Information)request.getAttribute(
					ApplicationCofOConstants.PROPERTY_INFO_SESSION_ATTR); 

Application_C_of_O applicatn =
	(Application_C_of_O)request.getAttribute(
			ApplicationCofOConstants.APPL_C_OF_O_SESSION_ATTR);

List<Held_Plots> heldPlots =(List<Held_Plots>) request.getAttribute("heldPlots");
int heldPlotsCounter =0;
if (heldPlots!= null){
	heldPlotsCounter = heldPlots.size();
}


%>

<liferay-portlet:actionURL name="savePropInformationStateLand" var="savePropInformationStateLand"></liferay-portlet:actionURL>

<liferay-ui:success key="property-information-save-success" message="property-information-save-success"></liferay-ui:success>


<portlet:defineObjects />

<portlet:resourceURL var="ajaxCallResourceURL" />
<aui:form  action="<%=savePropInformationStateLand.toString() %>"   method="post" name="savePropInformationStateLand_fm">
<% String app = applicatn.getApplication(); %>
 <div id="main">
	<%
	if("certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Certificate Of Occupancy</h1>
	<%
	}else if("re-certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Re-Certificate Of Occupancy</h1>
	<%
	}else {
	%>
	<h1>Application for State Land</h1>
	<%
	}
	%>
	
	<div class="content">

		<liferay-ui:error key="lga-is-mandatory" message="lga-is-mandatory" />
		<liferay-ui:error key="town-is-mandatory" message="town-is-mandatory" />
		<liferay-ui:error key="village-is-mandatory" message="village-is-mandatory" />
		<liferay-ui:error key="use-purpose-is-mandatory" message="use-purpose-is-mandatory" />
		<liferay-ui:error key="area-is-mandatory" message="area-is-mandatory" />
		<liferay-ui:error key="layout-is-mandatory" message="layout-is-mandatory" />
		<liferay-ui:error key="land-location-is-mandatory" message="land-location-is-mandatory" />
	
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			<td width="15%" valign="top">
				<aui:input name="applicationId" type="hidden" value="<%= applicatn.getApplicationId() %>"></aui:input>
				<aui:input name="buttonClicked" type="hidden" value=""></aui:input>
				<table width="100%" id="steps" cellpadding="0" cellspacing="0">
       		<tr><td valign="middle" align="center">STEP 1</td></tr>
       		<tr><td valign="middle" align="center">STEP 2</td></tr>
	        <tr><td valign="middle" align="center">STEP 3</td></tr>
          <tr><td valign="middle" align="center" class="current">STEP 4</td></tr>
          <tr><td valign="middle" align="center">STEP 5</td></tr>
          <tr><td valign="middle" align="center">STEP 6</td></tr>
          <tr><td valign="middle" align="center">STEP 7</td></tr>
          <tr><td valign="middle" align="center">STEP 8</td></tr>                               
       	</table>
			</td>
			<td width="85%" valign="top">
				<table width="100%" id="mainform">
					<tr>
						<td class="title" colspan="3">Property Information</td>
					</tr>
					<tr>
						<td colspan="2" align="right" style="padding-right: 20px">
							<hr>
							<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
			        <aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
			        <aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
							<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
						</td>
					</tr>
				
					<tr>
						<td colspan="2">
							<aui:field-wrapper name="locationType" label="Where is the Plot Located?">
								<%
								if ("town".equalsIgnoreCase(propInfo.getLocationType())){
								%>
								<aui:column columnWidth="33">
									<aui:input rel="town-sheet" checked="<%= true %>"  inlineLabel="right" name="locationType" type="radio" value="town" label="Town" />
								</aui:column>
								<aui:column columnWidth="33">
									<aui:input rel="layout-sheet"  inlineLabel="right" name="locationType" type="radio" value="layout" label="Layout" />			
								</aui:column>
								<%
								}else if  ("layout".equalsIgnoreCase(propInfo.getLocationType())){
								%>
								<aui:column columnWidth="33">
									<aui:input rel="town-sheet"   inlineLabel="right" name="locationType" type="radio" value="town" label="Town" />
								</aui:column>
								<aui:column columnWidth="33">
									<aui:input rel="layout-sheet" checked="<%= true %>" inlineLabel="right" name="locationType" type="radio" value="layout" label="Layout" />			
								</aui:column>
								<%
								}else{
								%>
								<aui:column columnWidth="33">
									<aui:input rel="town-sheet" checked="<%= true %>"  inlineLabel="right" name="locationType" type="radio" value="town" label="Town" />
								</aui:column>
								<aui:column columnWidth="33">
									<aui:input rel="layout-sheet"  inlineLabel="right" name="locationType" type="radio" value="layout" label="Layout" />			
								</aui:column>
								<%
								}
								%>
							</aui:field-wrapper>	
						</td>					
					</tr>
			
					<tr rel="town-sheet">
			    	<td colspan="2">
			      	<br>
			        <div align="left" id="town_sheet">
							  <aui:layout>
							  	<aui:column columnWidth="33">
					  				<%
										List<ListType> lga = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.lga.CROSS RIVER");
										%>
										<aui:select id="lga" name="lga" label="Local Government<span class='mandatoryfld'>*</span>">
											<option value="">-Please Select LGA-</option>
									  	<%
									  	String lgaFromLastSave=propInfo.getLga();
									  	for(int i=0; i<lga.size(); i++){
									  		ListType _useType = lga.get(i);
									  	%>	
									  	<aui:option selected="<%= propInfo.getLga().equalsIgnoreCase(lgaFromLastSave) %>" value="<%=_useType.getName() %>"><%=_useType.getName()  %></aui:option>
									  	<%
									  	}
									  	%>
										</aui:select>
							  	</aui:column>
							  	<aui:column columnWidth="33">
							    	<aui:input  name="town" value="<%= propInfo.getTown() %>" label="Town<span class='mandatoryfld'>*</span>"> </aui:input>
							    </aui:column>
							 		<aui:column columnWidth="33">
							  		<aui:input  name="village" value="<%= propInfo.getVillage() %>" label="Village<span class='mandatoryfld'>*</span>"> </aui:input>
							  	</aui:column>
							  </aui:layout> 
							  
					      <br>    
							  <aui:layout>
							  	<aui:column columnWidth="100">
							  		<aui:input name="otherUsefulInformation"  value="<%= propInfo.getOtherUsefulInformation() %>" label="Give full description of plot for ease of identification supported with a sketch plan showing dimensions:" type="textarea" style="width:400px"> </aui:input>
							  	</aui:column>
							  </aui:layout>      
					      
				      </div>
	         	</td>
	        </tr>
		
					<tr rel="layout-sheet">
			    	<td colspan="2">
			      	<br>
			        <div align="left" id="msgsendto">
			        	<aui:layout>
			          	<aui:column>
				          	<%
										List<ListType> layoutName = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.layout");
										%> 
										<aui:select  name="landLocation" id="landLocation"  label="Select Layout" >
											<option  style="font-style: italic; color: #A0A0A4" value="">--Please Select Layout--</option>
				  
		  								<%
		   									String layoutFromDB=propInfo.getLandLocation();
									  	for(int j=0; j<layoutName.size(); j++){
									  		ListType _layoutName = layoutName.get(j);
									  	%>	
									  	<aui:option selected="<%= _layoutName.getName().equalsIgnoreCase(layoutFromDB) %>" value="<%=_layoutName.getName() %>" ><%=_layoutName.getName()  %></aui:option>
											           
									  	<%
									  	}
									  	%>
										</aui:select>
			          	</aui:column>
		          	</aui:layout>
		          	
		          	<br>
		           	<aui:layout>
						  		<aui:column>
					  				<aui:input name="otherUsefulInformation" value="<%= propInfo.getOtherUsefulInformation() %>"
					  				label="Provide Particulars of Gazette Notice or Newspaper Publication by which advertisement was made:" type="textarea" style="width:400px"> </aui:input>
					  			</aui:column>
					  		</aui:layout> 
            	</div>
         		</td>
        	</tr>
        
       		<tr>
       			<td>
       				<br>
<%-- 							<aui:layout> --%>
<%-- 								<aui:column columnWidth="15"> --%>
									<aui:select name="term" label="Length of term applied for">
										<%
										int iTerm=1;
										if (heldPlotsCounter>0){
											String termFromDB=propInfo.getTerm();
											 iTerm = new Integer(termFromDB).intValue();
										}
												
										for (int i=1;i<100;i++){
											
										%>
										<aui:option selected="<%= i==iTerm %>"  value="<%= i %>" label="<%= i %>"></aui:option>		
										<%
										}
										%>
									</aui:select>
<%-- 								</aui:column> --%>
						</td>
						<td>
       				<br>
<%-- 								<aui:column columnWidth="30"> --%>
							<aui:select name="estDevCost" label="Estimated Cost of Development (&#8358;) ">
								<%
								String estDevCost=propInfo.getEstDevCost();
								%>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("1-5 Millions") %>' label="1-5 Millions" value="1-5 Million"></aui:option>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("6-10 Millions") %>' label="6-10 Millions" value="6-10 Millions"></aui:option>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("11-20 Millions") %>' label="11-20 Millions" value="11-20 Millions"></aui:option>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("21-30 Millions") %>' label="21-30 Millions" value="21-30 Millions"></aui:option>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("31-50 Millions") %>' label="31-50 Millions" value="31-50 Millions"></aui:option>
								<aui:option selected='<%= estDevCost.equalsIgnoreCase("50 Millions and Above") %>' label="50 Millions and Above" value="50 Millions and Above"></aui:option>
							</aui:select>
<%-- 								</aui:column> --%>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<br>
<%-- 						<aui:column columnWidth="55"> --%>
							<label class="aui-field-label">Time to start building<span class='mandatoryfld'>*</span></label>
							<%
							Calendar cal = CalendarFactoryUtil.getCalendar();
							if (propInfo.getEstStartDate() != null){ 
								cal.setTime(propInfo.getEstStartDate()); 
								//cal.setTime(individual.getDateOfBirth().getTime())); 
							} 
							
							Calendar current = CalendarFactoryUtil.getCalendar();
							%>	
							<liferay-ui:input-date formName="estStartDate"  
								dayParam="estStartDay"
							  dayValue="<%= cal.get(Calendar.DATE) %>"
							  disabled="<%= false %>"
							  firstDayOfWeek="<%= cal.getFirstDayOfWeek() - 1 %>"
							  monthParam="estStartMonth"
							  monthValue="<%= cal.get(Calendar.MONTH) %>"
							  yearParam="estStartYear"
							  yearValue="<%= cal.get(Calendar.YEAR) %>"
							  yearRangeStart="<%= current.get(Calendar.YEAR) %>"
							  yearRangeEnd="<%= current.get(Calendar.YEAR) +100  %>"
							/>
						</td>
					</tr>
		
	
					<tr>
					
					<td colspan="2">
						<br>
						<strong>Particulars of Plots held by applicant &nbsp;&nbsp;&nbsp; <%= heldPlotsCounter %>	</strong>
						<input type="hidden"  value="0" id="counter" name="counter" />
						<table border="thin solid #CCCCCC" cellpadding="0" cellspacing="0" id="tblparticulars" width="100%" >
							<tr class="ttitle">
								<td width="22%">Location</td>
								<td width="7%">Area(sq.m.)</td>
								<td width="16%">Is Plot Developed?</td>
								<td width="24%">Mode of Acquisition</td>
								<td width="16%">Registration Particulars</td>
								<td width="15%">&nbsp;</td>
							</tr>
							
							<%
							
							for (int i = 0; i <heldPlotsCounter; i++) {
								Held_Plots held_plotItem = heldPlots.get(i);
								
							%>
							<tr id="<%= i %>">
								<td>
									<%
									List<ListType> layoutName = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.layout");
									%> 
									<aui:select name="location_<%= i %>" id="location_<%= i %>"  label="" style="width:100%">
										<option  style="font-style: italic; color: #A0A0A4" value=""> &nbsp;</option>
			  						<%
								  	for(int j=0; j<layoutName.size(); j++){
								  		ListType _layoutName = layoutName.get(j);
								  		//
								  	%>	
										<aui:option selected="<%= held_plotItem.getLocation().equalsIgnoreCase(_layoutName.getName()) %>" value="<%=_layoutName.getName() %>" ><%=_layoutName.getName()  %></aui:option>
								  	<%
								  	}
								  	%>
									</aui:select> 
								</td>
										
							 	<td>
							 		<input value="<%= held_plotItem.getArea() %>" name="area_<%= i %>" id="area_<%= i %>" style="width:100%" type="text"></input>
							 	</td>
										
								<td>
							 		<aui:select id="developed_<%= i %>" name="developed_<%= i %>" label="">
										<aui:option  selected='<%= held_plotItem.getDeveloped().equalsIgnoreCase("Yes") %>' value="Yes" label="Yes"></aui:option>
								  	<aui:option selected='<%= held_plotItem.getDeveloped().equalsIgnoreCase("No") %>' value="No" label="No"></aui:option>
							 		</aui:select>
								</td>
								
								<td>
									<aui:select id="acquisition_<%= i %>" name="acquisition_<%= i %>" label="" style="width:100%">
										<aui:option  selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Inheriatance") %>' value="Inheriatance" label="Inheriatance"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Assignment") %>' value="Assignment" label="Assignment"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Transfer") %>' value="Transfer" label="Transfer"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Gift") %>' value="Gift" label="Gift"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Lease") %>' value="Lease" label="Lease"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Sublease") %>' value="Sublease" label="Sublease"></aui:option>
									  <aui:option selected='<%= held_plotItem.getAcquisitionMode().equalsIgnoreCase("Allocation") %>' value="Allocation" label="Allocation"></aui:option>
								 	</aui:select>
								</td>
								
								<td>
									<input type="text" value="<%= held_plotItem.getRegParticulars() %>" name="registration_<%= i %>" id="registration_<%= i %>" style="width:100%"></input>
								</td>
								
								<td>
									<input type="button" value="Delete" name="del_<%= i %>" id="del_<%= i %>" onclick="deletePlot('<%= held_plotItem.getHeld_id() %>');delRowFromPage('tblparticulars','<%= i %>')" ></input>
								</td>
										 
					 		</tr>
							<%
							}
							%>
								
						</table>
						<table>
						<tr>
						<td >
						<div >
											<%
											List<ListType> layoutName = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.layout");
					
											%> 
										<aui:select  style="display:none"  name="location" id="landLocation"  label="" >
										<option  style="font-style: italic; color: #A0A0A4" value="">--Please Select Layout--</option>
				  
				  								<%
				   							
											  	for(int j=0; j<layoutName.size(); j++){
											  		ListType _layoutName = layoutName.get(j);
											  	%>	
											  	<aui:option 
											             value="<%=_layoutName.getName() %>" ><%=_layoutName.getName()  %></aui:option>
											           
											  	<%
											  	}
											  	%>
										</aui:select>
										 <input id="countLayout" value="<%= layoutName.size() %>" type="hidden"></input>
															
						</div>
						</td>
						</tr>
						</table>
						
						<aui:button rel="particularsRow" value="Add" name="addanother" onClick="addParticularsRow('tblparticulars');"/>
						</td>
					</tr>	  	 	  	
		  			
				
					<tr>
						<td>
							<br>
							<%
							List<ListType> useTypes = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.land_use");
							%>
							<aui:select name="useType" label="Specify Required Land Use<span class='mandatoryfld'>*</span>" style="width:150px"
								onChange='<%= renderResponse.getNamespace() + "getPropertyUse(" + renderResponse.getNamespace()  + "useType.value);" %>'>
								<option value="">-Please Select Land Use-</option>
					  	
						  	<%
						  	String useType = applicatn.getLandUseType();
						  	for(int i=0; i<useTypes.size(); i++){
						  		ListType _useType = useTypes.get(i);
						  	%>	
						  	<aui:option selected="<%= _useType.getName().equalsIgnoreCase(useType)  %>" value="<%=_useType.getName() %>"><%=_useType.getName()  %></aui:option>
						  	<%
						  	}
						  	%>
							</aui:select>
						</td>
						  
						<td>
							<br>
							<aui:select id="purpose" name="purpose" label="Specify Purpose<span class='mandatoryfld'>*</span>" style="width:150px" />
							<input id="purposeSelected" type="hidden" value="<%= applicatn.getLandUsePurpose() %>"></input>
							<script>
								try{
									var purpose=document.getElementById('<portlet:namespace/>purpose');
									var purposeSelected=document.getElementById('purposeSelected').value;
									
									var selected = document.createElement('option'); 
									selected.appendChild(document.createTextNode(purposeSelected)); 
									purpose.appendChild(selected);
									//alert(useType);
									}
									catch (ex){
										alert(ex);
										}
							</script>	
						</td>
					</tr>
					
					<tr>
						<td colspan="2" align="right" style="padding-right: 20px">
							<hr>
							<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
			        <aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
			        <aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
							<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
						</td>
					</tr>
				
				</table>
			</td>
			</tr>
		</table>
	</div>

  <script type="text/javascript">
	function setButtonClicked(id)
	{
	   // alert(id);
	   document.<portlet:namespace/>savePropInformationStateLand_fm.<portlet:namespace/>buttonClicked.value=id;
	  // alert(document.<portlet:namespace/>quick_add_account_fm.<portlet:namespace/>buttonClicked.value);
	    //document.getElementById('jspPage').value=id;
	}

	</script>
</aui:form>



	<liferay-portlet:actionURL name="exitApplication" var="exitApplication"></liferay-portlet:actionURL>
	<form name="<portlet:namespace/>exitApplication_fm" method="post"	id="<portlet:namespace/>exitApplication_fm" action="<%=exitApplication.toString()%>"></form>
	<script type="text/javascript">
	<!--
	function exitApplication()
	{
		document.forms["<portlet:namespace/>exitApplication_fm"].submit();
	}
	//-->
	</script>
<script type="text/javascript">
<!--
	function confirmPost()
	{
	var agree=confirm("Cancelling the process will delete the record you have entered into the portal for this application. Do you want to proceed?");
	if (agree){
		document.forms["<portlet:namespace/>deleteApplication_fm"].submit();
		return true ;
	}
	else{
		return false ;
	}
	}
//-->
	var gRowId = 2;
function delRowFromPage(tableName,rowid){
		try{
			 var row = document.getElementById(rowid);
			 var table = document.getElementById(tableName);
			 table.deleteRow(rowid);
			   // tr.parentNode.removeChild(tr);
			var counter = (+parseInt(document.getElementById('counter').value) - 1 );
			}
		catch (ex){
			alert(ex);
			}

		}													
function delRow(button, tableName){
try{
											//.getElementsByTagName('tbody')[0]
	var row = button.parentNode.parentNode;
			
	var tbody = document.getElementById(tableName);
	tbody.removeChild(row);
	var counter = (+parseInt(document.getElementById('counter').value) - 1 );
	}
catch (ex){
	alert(ex);
	}

}
														
function addParticularsRow(tableName){
	var counter = (+parseInt(document.getElementById('counter').value) + 1 );
	
	var tbody = document.getElementById(tableName);
	var landLocation = document.getElementById('<portlet:namespace/>landLocation');
	var countLayout = document.getElementById('countLayout').value;
	
	var row = document.createElement('TR');
	var cell1 = document.createElement('TD');
	var cell2 = document.createElement('TD');
	var cell3 = document.createElement('TD');
	var cell4 = document.createElement('TD');
	var cell5 = document.createElement('TD');
	var cell6 = document.createElement('TD');
	
	
	
	//List<ListType> layoutName = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.layout");



		

			
	//For Cell 1
	var location = document.createElement("select");
	location.setAttribute('id', 'location_'+ counter);
	location.setAttribute('name', 'location_'+ counter);
	var NULL = document.createElement('option');  
	NULL.appendChild(document.createTextNode(' ')); 
	location.appendChild(NULL);
	location.style.width= '100%';
	
	for (i=0;i<=countLayout;i++){
		var layout = document.createElement('option'); 
		layout.appendChild(document.createTextNode(landLocation.options[i].value)); 
		location.appendChild(layout);
	}

  	
  	
	
												
	//For Cell2
	var area = document.createElement('input');
	area.setAttribute('id','area_'+ counter);
	area.setAttribute('name','area_'+ counter);
	area.setAttribute('type','text');
	area.setAttribute('maxlength','11');
	area.style.width = '100%';
	//'width', '150px'
	
	//For Cell3
	var developed = document.createElement("select");
	developed.setAttribute('id', 'developed_'+ counter);
	developed.setAttribute('name', 'developed_'+ counter);
	var yes = document.createElement('option'); 
	yes.appendChild(document.createTextNode('Yes')); 
	developed.appendChild(yes);
	var no = document.createElement('option'); 
	no.appendChild(document.createTextNode('No')); 
	developed.appendChild(no);
	
	//For Cell4
	
	var acquisition = document.createElement("select");
	acquisition.setAttribute('id', 'acquisition_'+ counter);
	acquisition.setAttribute('name', 'acquisition_'+ counter);
	acquisition.style.width= '100%';
	var NULL = document.createElement('option');  
	NULL.appendChild(document.createTextNode(' ')); 
	acquisition.appendChild(NULL);

	var inheriatance = document.createElement('option'); 
	inheriatance.appendChild(document.createTextNode('Inheriatance')); 
	acquisition.appendChild(inheriatance);
	
	var assignment = document.createElement('option'); 
	assignment.appendChild(document.createTextNode('Assignment')); 
	acquisition.appendChild(assignment);
	
	var transfer = document.createElement('option'); 
	transfer.appendChild(document.createTextNode('Transfer')); 
	acquisition.appendChild(transfer);
	
	var gift = document.createElement('option'); 
	gift.appendChild(document.createTextNode('Gift')); 
	acquisition.appendChild(gift);
	
	var lease = document.createElement('option'); 
	lease.appendChild(document.createTextNode('Lease')); 
	acquisition.appendChild(lease);
	
	var sublease = document.createElement('option'); 
	sublease.appendChild(document.createTextNode('Sublease')); 
	acquisition.appendChild(sublease);
	
	var allocation = document.createElement('option'); 
	allocation.appendChild(document.createTextNode('Allocation')); 
	acquisition.appendChild(allocation);
	
	//For Cell5
	var registration = document.createElement('input');
	registration.setAttribute('id','registration_'+ counter);
	registration.setAttribute('name','registration_'+ counter);
	registration.setAttribute('type','text');
	registration.setAttribute('maxlength','100');
	registration.style.width = '100%';
															
	//for Cell6
	var del = document.createElement('input');
	del.setAttribute('id','del');
	del.setAttribute('name','del');
	del.setAttribute('type','button');
	del.setAttribute('value','Delete');
														
	del.onclick = function() {delRow(del, tableName);}
		
	
	cell1.appendChild(location);
	cell2.appendChild(area);
	cell3.appendChild(developed);
	cell4.appendChild(acquisition);
	cell5.appendChild(registration);
	cell6.appendChild(del);
	
	
	row.appendChild(cell1);
	row.appendChild(cell2);
	row.appendChild(cell3);
	row.appendChild(cell4);
	row.appendChild(cell5);
	row.appendChild(cell6);
														
	tbody.appendChild(row);
	var counterControl = document.getElementById('counter');
	counterControl.value=counter;
										
	gRowId++;

	}
	
	
	
	
function addParticularsRowFromDB(tableName){
	
	var tbody = document.getElementById(tableName);
	var landLocation = document.getElementById('<portlet:namespace/>landLocation');
	var countLayout = document.getElementById('countLayout').value;
	
	var row = document.createElement('TR');
	var cell1 = document.createElement('TD');
	var cell2 = document.createElement('TD');
	var cell3 = document.createElement('TD');
	var cell4 = document.createElement('TD');
	var cell5 = document.createElement('TD');
	var cell6 = document.createElement('TD');
	
	
	

			
	//For Cell 1
	var location = document.createElement("select");
	location.setAttribute('id', 'location_'+ counter);
	location.setAttribute('name', 'location_'+ counter);
	var NULL = document.createElement('option');  
	NULL.appendChild(document.createTextNode(' ')); 
	location.appendChild(NULL);
	location.style.width= '100%';
	
	for (i=0;i<=countLayout;i++){
		var layout = document.createElement('option'); 
		layout.appendChild(document.createTextNode(landLocation.options[i].value)); 
		location.appendChild(layout);
	}

  	
  	
	
												
	//For Cell2
	var area = document.createElement('input');
	area.setAttribute('id','area_'+ counter);
	area.setAttribute('name','area_'+ counter);
	area.setAttribute('type','text');
	area.setAttribute('maxlength','11');
	area.style.width = '100%';
	//'width', '150px'
	
	//For Cell3
	var developed = document.createElement("select");
	developed.setAttribute('id', 'developed_'+ counter);
	developed.setAttribute('name', 'developed_'+ counter);
	var yes = document.createElement('option'); 
	yes.appendChild(document.createTextNode('Yes')); 
	developed.appendChild(yes);
	var no = document.createElement('option'); 
	no.appendChild(document.createTextNode('No')); 
	developed.appendChild(no);
	
	//For Cell4
	
	var acquisition = document.createElement("select");
	acquisition.setAttribute('id', 'acquisition_'+ counter);
	acquisition.setAttribute('name', 'acquisition_'+ counter);
	acquisition.style.width= '100%';
	var NULL = document.createElement('option');  
	NULL.appendChild(document.createTextNode(' ')); 
	acquisition.appendChild(NULL);

	var inheriatance = document.createElement('option'); 
	inheriatance.appendChild(document.createTextNode('Inheriatance')); 
	acquisition.appendChild(inheriatance);
	
	var assignment = document.createElement('option'); 
	assignment.appendChild(document.createTextNode('Assignment')); 
	acquisition.appendChild(assignment);
	
	var transfer = document.createElement('option'); 
	transfer.appendChild(document.createTextNode('Transfer')); 
	acquisition.appendChild(transfer);
	
	var gift = document.createElement('option'); 
	gift.appendChild(document.createTextNode('Gift')); 
	acquisition.appendChild(gift);
	
	var lease = document.createElement('option'); 
	lease.appendChild(document.createTextNode('Lease')); 
	acquisition.appendChild(lease);
	
	var sublease = document.createElement('option'); 
	sublease.appendChild(document.createTextNode('Sublease')); 
	acquisition.appendChild(sublease);
	
	var allocation = document.createElement('option'); 
	allocation.appendChild(document.createTextNode('Allocation')); 
	acquisition.appendChild(allocation);
	
	//For Cell5
	var registration = document.createElement('input');
	registration.setAttribute('id','registration_'+ counter);
	registration.setAttribute('name','registration_'+ counter);
	registration.setAttribute('type','text');
	registration.setAttribute('maxlength','100');
	registration.style.width = '100%';
															
	//for Cell6
	var del = document.createElement('input');
	del.setAttribute('id','del');
	del.setAttribute('name','del');
	del.setAttribute('type','button');
	del.setAttribute('value','Delete');
														
	del.onclick = function() {delRow(del, tableName);}
		
	
	cell1.appendChild(location);
	cell2.appendChild(area);
	cell3.appendChild(developed);
	cell4.appendChild(acquisition);
	cell5.appendChild(registration);
	cell6.appendChild(del);
	
	
	row.appendChild(cell1);
	row.appendChild(cell2);
	row.appendChild(cell3);
	row.appendChild(cell4);
	row.appendChild(cell5);
	row.appendChild(cell6);
														
	tbody.appendChild(row);
	var counterControl = document.getElementById('counter');
	counterControl.value=counter;
										
	gRowId++;

	}
</script>





<aui:script>
		
	Liferay.provide(window,
		'<portlet:namespace />getStates',
		function(countryName) {
	var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />countryName: countryName,
							<portlet:namespace />queryType: 'states',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
								
						document.getElementById('<portlet:namespace />city').options.length = 0;		
						document.getElementById('<portlet:namespace />state').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-select a state-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
							 for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option'); 
									
									if('CROSS RIVER' == message[param]){
										//state.appendChild(document.createTextNode(message." + param + ")); 
										state.appendChild(document.createTextNode(message[param]));
										oFieldSelect.appendChild(state); 
									}

								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide


Liferay.provide(window,
		'<portlet:namespace />getLGA',
		function(stateName) {
			var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />stateName: stateName,
							<portlet:namespace />queryType: 'LGA',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
						document.getElementById('<portlet:namespace />city').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-select a LGA-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
								  for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option'); 
									
						
									//state.appendChild(document.createTextNode(message." + param + ")); 
									state.appendChild(document.createTextNode(message[param]));
									oFieldSelect.appendChild(state); 
									  
								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide
	
	Liferay.provide(window,
		'<portlet:namespace />getPropertyUse',
		function(landUse) {
			var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />landUse: landUse,
							<portlet:namespace />queryType: 'landUse',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
						document.getElementById('<portlet:namespace />purpose').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Please specify purpose-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
								  for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option'); 
									
						
									//state.appendChild(document.createTextNode(message." + param + ")); 
									state.appendChild(document.createTextNode(message[param]));
									oFieldSelect.appendChild(state); 
									  
								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide
	
</aui:script>

<liferay-portlet:actionURL name="deleteApplication" var="deleteApplication"></liferay-portlet:actionURL>
 <aui:form action="<%=deleteApplication.toString() %>" method="post" name="deleteApplication_fm">
  	<aui:input name="applicationId" type="hidden" value="<%= propInfo.getApplicationId() %>"></aui:input>
 </aui:form>
<aui:script>
	Liferay.provide(window,
		'deletePlot',
		function(heldPlotId) {
	
			var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />heldPlotId: heldPlotId, 
							<portlet:namespace />queryType: "heldPlot",
							
							

							
							
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								
							
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide
	
</aui:script>

 